#include <benchmark/benchmark.h>
#include <iostream>

#include "Exception.h"

static void NoException(benchmark::State & state){
  auto times = state.range(0);
  int sum = 0;
  for( auto _ : state){
    for(int i = 0 ; i < times; ++i){
      sum += no_exception(i);  
    }
  }
  std::cout << sum << std::endl;
}

#define TIMES (1000*1000)

BENCHMARK(NoException)
  ->Unit(benchmark::kMillisecond)
  ->Arg(TIMES)
  ;


static void Exception(benchmark::State& state) {
  auto times = state.range(0);
  int sum = 0;
  for (auto _ : state){
    for( int i = 0;  i < times; ++i){
      sum += exception(i);
    }
  }
  std::cout << sum << std::endl;
}

BENCHMARK(Exception)
  ->Unit(benchmark::kMillisecond)
  ->Arg(TIMES)
  ;
